package cn.jsj.dispose;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.jsj.object.FrontAssistInfo;
import cn.jsj.pojo.TblLawyAssistant;
import cn.jsj.utils.ProduceJsonData;
import cn.jsj.utils.SysLogger;

/**
 * 加载所有律师助理信息
 * @author LI
 *
 */
 public class LawyerAssistInfoRequest extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
	 public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//调试信息
		 cn.jsj.utils.SysLogger.PrintInfo("加载所有律师助理信息！！！");

		//获得参数：1.第几条开始。2.一页显示几条
			int startNumb=Integer.parseInt(request.getParameter("start"));
			int totalNumb=Integer.parseInt(request.getParameter("limit"));

			//调试信息
			cn.jsj.utils.SysLogger.PrintInfo("start---->"+startNumb+"   total--------->"+totalNumb);

			//获得律师助理信息条数
			cn.jsj.dao.TblLawyAssistantDAO tlad=new cn.jsj.dao.TblLawyAssistantDAO();
			int lawyerAssistNumber=tlad.getLawyerAssistInfoNumb();

		//暂存律师助理信息队列
		java.util.List<TblLawyAssistant> lawyerAssistInfo=new java.util.LinkedList<TblLawyAssistant>();

		//获取这个页面要显示的律师信息
		lawyerAssistInfo=tlad.getTheLawyerAssistInfo(startNumb, totalNumb);

		//调试信息
		SysLogger.PrintInfo(lawyerAssistInfo.size());

		//前台律师助理信息对象队列
		java.util.List<FrontAssistInfo> frontLawyerAssistInfo=new java.util.LinkedList<FrontAssistInfo>();

		//改造成前台需要的律师助理信息对象
		cn.jsj.object.rebuild.FrontLawyerAssistRebuild flar=new cn.jsj.object.rebuild.FrontLawyerAssistRebuild();
		for(int i=0;i<lawyerAssistInfo.size();i++){
			cn.jsj.object.FrontAssistInfo fai=flar.rebulidAssistInfo(lawyerAssistInfo.get(i));
			frontLawyerAssistInfo.add(fai);
		}

		//改造成JSON型数据
		ProduceJsonData pjd=new ProduceJsonData();
	String resultData=	pjd.jsonFromList(frontLawyerAssistInfo,lawyerAssistNumber);

	//调试信息
	SysLogger.PrintInfo(resultData);
	//输出到客户端
	java.io.PrintWriter pw=response.getWriter();
	pw.println(resultData);
	pw.flush();
	}
}